package com.carrara.helloworld;

import java.util.Random;
import java.util.Scanner;

public class Randof {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		System.out.println("There is a monster!");

		int mhealth = 20;
		int yhealth = 20;

		while (yhealth > 0 && mhealth > 0) {
			System.out.println("Your health is " + yhealth + ".");
			System.out.println("The monster's health is " + mhealth + ".");
			System.out
					.println("You can currently kick or punch, what would you like to do?");

			Scanner fightchoice = new Scanner(System.in);
			String fightchoicestr = fightchoice.next();

			if (fightchoicestr.equalsIgnoreCase("punch")) {
				Random dpunch = new Random();
				dpunch.nextInt(6);
				
				int dpuncher= dpunch.nextInt();

				if (dpuncher < 1) {
					System.out.println("Your attack missed!");
				} else {
					System.out.println("Your attack did " + dpuncher
							+ " damage!");
					mhealth -= dpuncher;
					System.out.println("The monster is at " + mhealth
							+ " health!");
				}
			} else if (fightchoicestr.equalsIgnoreCase("kick")) {
				Random dkick= new Random();
				dkick.nextInt(10);
				
				int dkicker = dkick.nextInt();

				if (dkicker < 5) {
					System.out.println("Your attack missed!");
				} else {
					System.out.println("Your attack did " + dkicker
							+ " damage!");
					mhealth -= dkicker;
					System.out.println("The monster is at " + mhealth
							+ " health!");
				}
			} else {
				System.out.println("That is an invalid move!");
			}
			
			System.out.println("The monster attacks!");
			
			Random mattack= new Random();
			mattack.nextInt(4);
			
			int mattacker = mattack.nextInt();
			
			if (mattacker < 3)
			{
				System.out.println("The attack missed!");
			}
			else
			{
				System.out.println("The attack did "+mattacker+" damage!");
				yhealth -= mattacker;
				System.out.println("You are down to "+yhealth+" health!");
			}
		}

	}

}
